package com.bhsy.hellobootspring.service.Impl;

import com.bhsy.hellobootspring.dao.UserInterface;
import com.bhsy.hellobootspring.model.User;
import com.bhsy.hellobootspring.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService
{
    @Resource
    private UserInterface userInterface;
    @Override
    public int addUser(User user) {
        return userInterface.insertUser(user);
    }
    @Override
    public boolean UserAll(User user)
      {
        List<User> list = userInterface.selectUserAll();
        for(int a = 0 ; a<list.size() ; a++)
          {
            System.out.println(list.get(a));
            if(user.getUsername().equals(list.get(a).getUsername()) && user.getPassword().equals(list.get(a).getPassword()))
              {
                System.out.println("true");
                return true;
              }
          }
        System.out.println("false");
        return false;
      }

}
